package com.yuexunit.mobilenurse.module.BloodManage.ui;

import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yuexunit.mobilenurse.R;
import com.yuexunit.mobilenurse.base.titlebar.TitleBar_DocAdvice;
import com.yuexunit.mobilenurse.config.AppConfig;
import com.yuexunit.mobilenurse.module.BloodManage.bean.BloodBag;
import com.yuexunit.mobilenurse.module.BloodManage.bean.CheckDataBean;
import com.yuexunit.mobilenurse.module.BloodManage.model.impl.CheckModel;
import com.yuexunit.mobilenurse.module.BloodManage.presenter.ICheckPresenter;
import com.yuexunit.mobilenurse.module.BloodManage.presenter.impl.CheckPresenter;
import com.yuexunit.mobilenurse.module.BloodManage.ui.view.ICheckView;
import com.yuexunit.mobilenurse.module.Login.bean.YXLoginData;
import com.yuexunit.mobilenurse.widget.Dialog_Success;
import com.yuexunit.mobilenurse.widget.LoadingDialog;
import com.yuexunit.mobilenurse.widget.LoginDialog;

import org.kymjs.kjframe.ui.ViewInject;
import org.kymjs.kjframe.utils.PreferenceHelper;
import org.kymjs.kjframe.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by work-jx on 2017/10/13.
 */
public class Act_Blood_BloodDetail extends TitleBar_DocAdvice implements ICheckView {
    @Bind(R.id.titlebar_docadvice_tv_title)
    public TextView titlebar_docadvice_tv_title;
    @Bind(R.id.docactvice_name)
    public TextView docactvice_name;
    @Bind(R.id.docactvice_bedno)
    public TextView docactvice_bedno;
    @Bind(R.id.docactvice_visitno)
    public TextView docactvice_visitno;
    @Bind(R.id.blood_blooddetail_no_tv)
    TextView bloodBlooddetailNoTv;
    @Bind(R.id.testlist_item_num)
    TextView testlistItemNum;
    @Bind(R.id.testlist_item_statu)
    TextView testlistItemStatu;
    @Bind(R.id.testlist_item_name)
    TextView testlistItemName;
    @Bind(R.id.testlist_item_unit)
    TextView testlistItemUnit;
    @Bind(R.id.before_name_tv_01)
    TextView beforeNameTv01;
    @Bind(R.id.before_name_tv_02)
    TextView beforeNameTv02;
    @Bind(R.id.start_name_tv_01)
    TextView startNameTv01;
    @Bind(R.id.start_name_tv_02)
    TextView startNameTv02;
    @Bind(R.id.after_15_name_edt)
    EditText after15NameEdt;
    @Bind(R.id.over_name_edt)
    EditText overNameEdt;
    @Bind(R.id.over_4_name_edt)
    EditText over4NameEdt;
    @Bind(R.id.before_name_tv_login)
    TextView beforeNameTvLogin;
    @Bind(R.id.start_name_tv_login)
    TextView startNameTvLogin;
    @Bind(R.id.after_15_name_tv_login)
    TextView after15NameTvLogin;
    @Bind(R.id.over_name_tv_login)
    TextView overNameTvLogin;
    @Bind(R.id.over_4_name_tv_login)
    TextView over4NameTvLogin;
    @Bind(R.id.before_name_tv_statu)
    TextView beforeNameTvStatu;
    @Bind(R.id.start_name_tv_statu)
    TextView startNameTvStatu;
    @Bind(R.id.cancle_tv_sure)
    TextView cancleTvSure;
    @Bind(R.id.cancle_name_tv_sure)
    TextView cancleNameTvSure;
    @Bind(R.id.cancle_ll)
    LinearLayout cancleLl;
    @Bind(R.id.exec_ll)
    LinearLayout execLl;
    @Bind(R.id.tv_after_15_date)
    TextView tvAfter15Date;
    @Bind(R.id.tv_begin_15_name)
    TextView tvBegin15Name;
    @Bind(R.id.tv_begin_15_jobnum)
    TextView tvBegin15Jobnum;
    @Bind(R.id.after_15_ll)
    RelativeLayout after15Ll;
    @Bind(R.id.tv_finish_date)
    TextView tvFinishDate;
    @Bind(R.id.tv_finish_name)
    TextView tvFinishName;
    @Bind(R.id.tv_finish_jobnum)
    TextView tvFinishJobnum;
    @Bind(R.id.finish_ll)
    RelativeLayout finishLl;
    @Bind(R.id.tv_finish_4_date)
    TextView tvFinish4Date;
    @Bind(R.id.tv_finish_4_name)
    TextView tvFinish4Name;
    @Bind(R.id.tv_finish_4_jobnum)
    TextView tvFinish4Jobnum;
    @Bind(R.id.finish_4_ll)
    RelativeLayout finish4Ll;

    //记录Log
    private final Logger log = LoggerFactory.getLogger(Act_Blood_BloodDetail.class);

    LoginDialog loginDialog;
    Dialog_Success.Builder builder_success;
    int type = 0;

    String requireNo;
    BloodBag bloodBag;

    LoadingDialog dialog;

    String checkName;
    String checkNum;
    String checkTime;

    ICheckPresenter presenter;


    @Override
    public void setRootView() {
        setContentView(R.layout.act_blood_blooddetail);
        ButterKnife.bind(this);
        requireNo = getIntent().getExtras().getString("requireNo");
        bloodBag = (BloodBag) getIntent().getExtras().get("bloodbag");
    }

    @Override
    public void initData() {
        presenter = new CheckPresenter(new CheckModel(), this);
        dialog = new LoadingDialog(this);
        loginDialog = new LoginDialog(aty);
        bloodBlooddetailNoTv.setText(requireNo);
        testlistItemNum.setText("血袋编号:" + bloodBag.getHisBagNo());
        testlistItemStatu.setText("");
        testlistItemName.setText(bloodBag.getBloodKind());
        testlistItemUnit.setText(bloodBag.getBloodNum());

        if (bloodBag.getCancleStatus().equals("-1")) {
            execLl.setVisibility(View.GONE);
            cancleTvSure.setVisibility(View.GONE);
            cancleNameTvSure.setVisibility(View.VISIBLE);
        }

        if (bloodBag.getBeforeTime().length() > 0) {
            beforeNameTvLogin.setVisibility(View.GONE);
            beforeNameTv01.setVisibility(View.VISIBLE);
            beforeNameTv02.setVisibility(View.VISIBLE);
            beforeNameTvStatu.setVisibility(View.VISIBLE);
            beforeNameTv01.setText(bloodBag.getBeforeName() + "  " + bloodBag.getBeforeJobNum());
            beforeNameTv02.setText(bloodBag.getBeforeAuditName() + "  " + bloodBag.getBeforeAuditJobNum());
        }

        if (bloodBag.getBeginTime().length() > 0) {
            cancleLl.setVisibility(View.GONE);
            startNameTvLogin.setVisibility(View.GONE);
            startNameTv01.setVisibility(View.VISIBLE);
            startNameTv02.setVisibility(View.VISIBLE);
            startNameTvStatu.setVisibility(View.VISIBLE);
            startNameTv01.setText(bloodBag.getBeginName() + "  " + bloodBag.getBeginJobNum());
            startNameTv02.setText(bloodBag.getBeginAuditName() + "  " + bloodBag.getBeginAuditJobNum());
        }

        if (bloodBag.getBeginConfirmTime().length() > 0) {
            after15NameEdt.setText(bloodBag.getBeginConfirmRemark());
            after15NameEdt.setFocusable(false);
            after15NameEdt.setEnabled(false);
            after15NameTvLogin.setVisibility(View.GONE);
            after15Ll.setVisibility(View.VISIBLE);
            tvAfter15Date.setText(bloodBag.getBeginConfirmTime());
            tvBegin15Name.setText(bloodBag.getBeginConfirmName());
            tvBegin15Jobnum.setText(bloodBag.getBeginConfirmJobNum());
        }

        if (bloodBag.getFinishTime().length() > 0) {
            overNameEdt.setText(bloodBag.getFinishRemark());
            overNameEdt.setFocusable(false);
            overNameEdt.setEnabled(false);
            overNameTvLogin.setVisibility(View.GONE);
            finishLl.setVisibility(View.VISIBLE);
            tvFinishDate.setText(bloodBag.getFinishTime());
            tvFinishName.setText(bloodBag.getFinishName());
            tvFinishJobnum.setText(bloodBag.getFinishJobNum());
        }

        if (bloodBag.getFinishConfirmTime().length() > 0) {
            over4NameEdt.setText(bloodBag.getFinishConfirmRemark());
            over4NameEdt.setFocusable(false);
            over4NameEdt.setEnabled(false);
            over4NameTvLogin.setVisibility(View.GONE);
            finish4Ll.setVisibility(View.VISIBLE);
            tvFinish4Date.setText(bloodBag.getFinishConfirmTime());
            tvFinish4Name.setText(bloodBag.getFinishConfirmName());
            tvFinish4Jobnum.setText(bloodBag.getFinishConfirmJobNum());
        }
    }

    @Override
    public void setTitle() {
        titlebar_docadvice_tv_title.setText("输血执行");
        docactvice_name.setText(PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_NAME));
        docactvice_bedno.setText(PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_BEDCODE));
        docactvice_visitno.setText(PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
    }


    @OnClick({R.id.titlebar_docadvice_img_back, R.id.before_name_tv_login,
            R.id.start_name_tv_login, R.id.after_15_name_tv_login,
            R.id.over_name_tv_login, R.id.over_4_name_tv_login, R.id.cancle_tv_sure})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.titlebar_docadvice_img_back:
                finish();
                break;
            case R.id.before_name_tv_login:
                showTypeDialog();
                type = 1;
                break;
            case R.id.start_name_tv_login:
                showTypeDialog();
                type = 2;
                break;
            case R.id.after_15_name_tv_login:
                if (after15NameEdt.getText().toString().length() > 0) {
                    showSure_after_15();
                } else {
                    ViewInject.toast("请输入不良反应后，再提交");
                }
                break;
            case R.id.over_name_tv_login:
                if (overNameEdt.getText().toString().length() > 0) {
                    showSure_over();
                } else {
                    ViewInject.toast("请输入不良反应后，再提交");
                }
                break;
            case R.id.over_4_name_tv_login:
                if (over4NameEdt.getText().toString().length() > 0) {
                    showSure_over_4();
                } else {
                    ViewInject.toast("请输入不良反应后，再提交");
                }
                break;
            case R.id.cancle_tv_sure:
                show_cancle();
                break;
        }
    }

    private void showTypeDialog() {

        loginDialog.builder();
        Boolean islogin = PreferenceHelper.readBoolean(this, AppConfig.REVIEW_INFO, AppConfig.REVIEW_ISLOGIN);
        if (islogin) {
            loginDialog.setTxt(PreferenceHelper.readString(this, AppConfig.REVIEW_INFO, AppConfig.REVIEW_NAME),
                    PreferenceHelper.readString(this, AppConfig.REVIEW_INFO, AppConfig.REVIEW_PASSWORD));
        }
        loginDialog.show();
        loginDialog.setCallBack(new LoginDialog.ICallBack() {
            @Override
            public void callback(Bundle bundle) {
                Map<String, String> params = new HashMap<>();
                params.put("jobNum", bundle.getString("person_num"));
                params.put("loginPwd", bundle.getString("person_psw"));

                // 自动账号登入
                if (bundle.getString("auditSave").equals("1")) {
                    PreferenceHelper.write(aty, AppConfig.REVIEW_INFO, AppConfig.REVIEW_ISLOGIN, true);
                    PreferenceHelper.write(aty, AppConfig.REVIEW_INFO, AppConfig.REVIEW_NAME, bundle.getString("person_num"));
                    PreferenceHelper.write(aty, AppConfig.REVIEW_INFO, AppConfig.REVIEW_PASSWORD, bundle.getString("person_psw"));
                } else {
                    PreferenceHelper.write(aty, AppConfig.REVIEW_INFO, AppConfig.REVIEW_ISLOGIN, false);
                }
                presenter.doInLogin(bundle.getString("person_num"), bundle.getString("person_psw"));
            }
        });
    }

    public void showSure_before() {
        builder_success = new Dialog_Success.Builder(aty);
        builder_success.setMessage("是否确认核对条码信息");
        builder_success.setPositiveButton("确认",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        Map<String, String> params = new HashMap<>();
                        params.put("visitNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
                        params.put("bagNo", bloodBag.getHisBagNo());
                        params.put("hisJobNum", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
                        params.put("jobName", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME));
                        params.put("auditJobNum", checkNum);
                        params.put("auditJobName", checkName);
                        params.put("checkTime", StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
                        TelephonyManager telephonyManager = (TelephonyManager) aty
                                .getSystemService(Context.TELEPHONY_SERVICE);
                        params.put("setNo", telephonyManager.getDeviceId());

                        presenter.checkBlood(params);
                    }
                });

        builder_success.setNegativeButton("取消",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        builder_success.create().show();
    }

    public void showSure_start() {
        builder_success = new Dialog_Success.Builder(aty);
        builder_success.setMessage("是否确认执行输血操作");
        builder_success.setPositiveButton("确认",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        Map<String, String> params = new HashMap<>();
                        params.put("visitNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
                        params.put("bagNo", bloodBag.getHisBagNo());
                        params.put("hisJobNum", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
                        params.put("jobName", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME));
                        params.put("auditJobNum", checkNum);
                        params.put("auditJobName", checkName);
                        params.put("beginTime", StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
                        TelephonyManager telephonyManager = (TelephonyManager) aty
                                .getSystemService(Context.TELEPHONY_SERVICE);
                        params.put("setNo", telephonyManager.getDeviceId());

                        presenter.beginBlood(params);
                    }
                });

        builder_success.setNegativeButton("取消",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        builder_success.create().show();
    }

    public void showSure_after_15() {
        builder_success = new Dialog_Success.Builder(aty);
        builder_success.setMessage("是否确认输入不良反应");
        builder_success.setPositiveButton("确认",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        Map<String, String> params = new HashMap<>();
                        params.put("visitNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
                        params.put("bagNo", bloodBag.getHisBagNo());
                        checkNum=PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID);
                        checkName=PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME);
                        checkTime=StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss");
                        params.put("hisJobNum", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
                        params.put("jobName", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME));
                        params.put("remark", after15NameEdt.getText().toString());
                        params.put("confirmTime", checkTime);
                        TelephonyManager telephonyManager = (TelephonyManager) aty
                                .getSystemService(Context.TELEPHONY_SERVICE);
                        params.put("setNo", telephonyManager.getDeviceId());

                        presenter.beginConfirmBlood(params);
                    }
                });

        builder_success.setNegativeButton("取消",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        builder_success.create().show();
    }

    public void showSure_over() {
        builder_success = new Dialog_Success.Builder(aty);
        builder_success.setMessage("是否确认输入不良反应");
        builder_success.setPositiveButton("确认",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        Map<String, String> params = new HashMap<>();
                        params.put("visitNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
                        params.put("bagNo", bloodBag.getHisBagNo());
                        checkNum=PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID);
                        checkName=PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME);
                        checkTime=StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss");
                        params.put("hisJobNum", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
                        params.put("jobName", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME));
                        params.put("remark", overNameEdt.getText().toString());
                        params.put("finishTime", checkTime);
                        TelephonyManager telephonyManager = (TelephonyManager) aty
                                .getSystemService(Context.TELEPHONY_SERVICE);
                        params.put("setNo", telephonyManager.getDeviceId());

                        presenter.finishBlood(params);
                    }
                });

        builder_success.setNegativeButton("取消",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        builder_success.create().show();
    }

    public void showSure_over_4() {
        builder_success = new Dialog_Success.Builder(aty);
        builder_success.setMessage("是否确认输入不良反应");
        builder_success.setPositiveButton("确认",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        Map<String, String> params = new HashMap<>();
                        params.put("visitNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
                        params.put("bagNo", bloodBag.getHisBagNo());
                        checkNum=PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID);
                        checkName=PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME);
                        checkTime=StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss");
                        params.put("confirmJobNum", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
                        params.put("confirmJobName", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME));
                        params.put("remark", over4NameEdt.getText().toString());
                        params.put("confirmTime", checkTime);
                        TelephonyManager telephonyManager = (TelephonyManager) aty
                                .getSystemService(Context.TELEPHONY_SERVICE);
                        params.put("setNo", telephonyManager.getDeviceId());

                        presenter.finishConfirmBlood(params);
                    }
                });

        builder_success.setNegativeButton("取消",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        builder_success.create().show();
    }

    public void show_cancle() {
        builder_success = new Dialog_Success.Builder(aty);
        builder_success.setMessage("是否确认退血");
        builder_success.setPositiveButton("确认",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        Map<String, String> params = new HashMap<>();
                        params.put("visitNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_VISITNO));
                        params.put("bagNo", bloodBag.getHisBagNo());
                        params.put("cancelJobNum", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
                        params.put("cancelJobName", PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME));
                        params.put("bedNo", PreferenceHelper.readString(aty, AppConfig.CURRENT_PATIENT_INFO, AppConfig.CURRENT_PATIENT_BEDCODE));
//                        params.put("confirmTime", StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
//                        TelephonyManager telephonyManager = (TelephonyManager) aty
//                                .getSystemService(Context.TELEPHONY_SERVICE);
//                        params.put("setNo", telephonyManager.getDeviceId());

                        presenter.cancle(params);
                    }
                });

        builder_success.setNegativeButton("取消",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        builder_success.create().show();
    }

    @Override
    public void checkBlood(CheckDataBean checkDataBean) {
        if (checkDataBean.getStatus().equals("200")) {
            beforeNameTvLogin.setVisibility(View.GONE);
            beforeNameTv01.setVisibility(View.VISIBLE);
            beforeNameTv02.setVisibility(View.VISIBLE);
            beforeNameTvStatu.setVisibility(View.VISIBLE);

            beforeNameTv01.setText(checkName + "  " + checkNum);
            beforeNameTv02.setText(PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME)
                    + "  " + PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
        } else {
            ViewInject.toast("核对失败");
        }
    }

    @Override
    public void beginBlood(CheckDataBean checkDataBean) {
        if (checkDataBean.getStatus().equals("200")) {
            cancleLl.setVisibility(View.GONE);

            startNameTvLogin.setVisibility(View.GONE);
            startNameTv01.setVisibility(View.VISIBLE);
            startNameTv02.setVisibility(View.VISIBLE);
            startNameTvStatu.setVisibility(View.VISIBLE);

            startNameTv01.setText(checkName + "  " + checkNum);
            startNameTv02.setText(PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGNAME)
                    + "  " + PreferenceHelper.readString(aty, AppConfig.NURSE_INFO, AppConfig.NURSE_LOGID));
        } else {
            ViewInject.toast("开始输血失败");
        }
    }

    @Override
    public void beginConfirmBlood(CheckDataBean checkDataBean) {
        if (checkDataBean.getStatus().equals("200")) {
            ViewInject.toast("开始输血15分钟后确认成功");
            after15NameEdt.setFocusable(false);
            after15NameEdt.setEnabled(false);
            after15NameTvLogin.setVisibility(View.GONE);

            after15Ll.setVisibility(View.VISIBLE);
            tvAfter15Date.setText(checkTime);
            tvBegin15Name.setText(checkName);
            tvBegin15Jobnum.setText(checkNum);
        } else {
            ViewInject.toast("开始输血15分钟后确认失败");
        }
    }

    @Override
    public void finishBlood(CheckDataBean checkDataBean) {
        if (checkDataBean.getStatus().equals("200")) {
            ViewInject.toast("结束输血成功");
            overNameEdt.setFocusable(false);
            overNameEdt.setEnabled(false);
            overNameTvLogin.setVisibility(View.GONE);

            finishLl.setVisibility(View.VISIBLE);
            tvFinishDate.setText(checkTime);
            tvFinishName.setText(checkName);
            tvFinishJobnum.setText(checkNum);
        } else {
            ViewInject.toast("结束输血失败");
        }
    }

    @Override
    public void finishConfirmBlood(CheckDataBean checkDataBean) {
        if (checkDataBean.getStatus().equals("200")) {
            ViewInject.toast("结束输血4小时后确认成功");
            over4NameEdt.setFocusable(false);
            over4NameEdt.setEnabled(false);
            over4NameTvLogin.setVisibility(View.GONE);

            finish4Ll.setVisibility(View.VISIBLE);
            tvFinish4Date.setText(checkTime);
            tvFinish4Name.setText(checkName);
            tvFinish4Jobnum.setText(checkNum);
        } else {
            ViewInject.toast("结束输血4小时后确认失败");
        }
    }

    @Override
    public void cancle(CheckDataBean checkDataBean) {
        if (checkDataBean.getStatus().equals("200")) {
            ViewInject.toast("退血成功");
            execLl.setVisibility(View.GONE);
            cancleTvSure.setVisibility(View.GONE);
            cancleNameTvSure.setVisibility(View.VISIBLE);
        } else {
            ViewInject.toast("退血失败");
        }
    }

    @Override
    public void doInLogin(YXLoginData yxLoginData) {
        loginDialog.dismiss();
        checkName = yxLoginData.getResponse().getEmpinfo().getLogname();
        checkNum = yxLoginData.getResponse().getEmpinfo().getLogid();
        switch (type) {
            case 1:
                showSure_before();
                break;
            case 2:
                showSure_start();
                break;
        }
    }

    @Override
    public void loadingDialogStatus(int status) {
        switch (status) {
            case AppConfig.SHOW_DIALOG:
                dialog.setCanceledOnTouchOutside(false);
                dialog.show();
                break;

            case AppConfig.DISMISS_DIALOG:
                dialog.dismiss();
                break;

        }
    }
}
